<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="/pages/layout/mainLayout.xhtml">
	<ui:define name="bodySemUsuario">
		<div class="post">
		<h2 class="title"><h:outputText
			value="#{filmeBean.entity.titulo}" /> <font style="color: red"><h:outputText
			value="#{filmeBean.entity.status==1?'':'[Inativo]'}" /></font></h2>
		<div class="sinopse">
			<img class="filme" src="#{facesContext.externalContext.request.contextPath}/imgview?img=#{filmeBean.entity.id}"/>
			<h:outputText escape="false"
			value="#{filmeBean.entity.descricao}" /></div>
		<h:panelGrid columns="2">
			<h:outputLabel value="#{bundle['locanet.Filme.dataLancamento']}" />
			<h:outputText value="#{filmeBean.entity.dataChegada}">
				<f:convertDateTime pattern="dd/MM/yyyy" />
			</h:outputText>

			<h:outputText value="#{bundle['locanet.Filme.numCopias']}" />
			<h:outputText value="#{filmeBean.numCopias}" />

			<h:outputLabel value="#{bundle['locanet.Filme.valLocacao']}" />
			<h:outputText value="#{bundle['locanet.Filme.signal']} #{filmeBean.entity.precoLocacao}" />

			<h:outputText />
			<h:column>
				<h:form>
					<h:inputHidden value="#{filmeBean.entity.id}" />
					<h:commandButton rendered="#{loginBean.funcionario}"
						action="#{filmeBean.openUpdate}"
						value="#{bundle['locanet.entidades.lista.editar']}">
						<f:setPropertyActionListener value="#{filmeBean.entity.id}" target="#{filmeBean.entity.id}"/>
					</h:commandButton>
					<h:commandButton rendered="#{loginBean.funcionario}"
						action="#{filmeBean.remove}"
						value="#{bundle['locanet.entidades.lista.excluir']}">
						<f:setPropertyActionListener value="#{filmeBean.entity.id}" target="#{filmeBean.entity.id}"/>
					</h:commandButton>
					<h:commandButton rendered="#{loginBean.cliente}"
						action="#{locacaoBean.addNoCarrinho}"
						value="#{bundle['locanet.locacoes.adicionarCarrinho']}">
						<f:setPropertyActionListener value="#{filmeBean.entity.id}" target="#{locacaoBean.entity.filme.id}"/>
					</h:commandButton>
				</h:form>
			</h:column>
		</h:panelGrid></div>
		<p:outputPanel rendered="#{loginBean.funcionario}" styleClass="post">
				<h2 class="title"><h:outputText value="#{bundle['locanet.Filme.copias']}" /></h2>
				<h:form>
					<h:inputHidden value="#{filmeBean.entity.id}" />
					<p:dataTable value="#{filmeBean.copiasFilme}" var="cf">
			
						<p:column>
							<f:facet name="header">
								<h:outputText value="#{bundle['locanet.Filme.codigo']}" />
							</f:facet>
							<h:outputText value="#{cf.codigo}" />
						</p:column>
			
						<p:column>
							<f:facet name="header">
								<h:outputText value="#{bundle['locanet.status']}" />
							</f:facet>
							<font style="color: green"><h:outputText
								rendered="#{cf.status==1}"
								value="#{bundle['locanet.entidades.status.ativo']}" /></font>
							<font style="color: #CCCC00"><h:outputText
								rendered="#{cf.status==2}"
								value="#{bundle['locanet.entidades.status.locado']}" /></font>
							<font style="color: red"><h:outputText
								rendered="#{cf.status==0}"
								value="#{bundle['locanet.entidades.status.inativo']}" /></font>
						</p:column>
						
						<p:column>
							<h:commandLink value="#{bundle['locanet.entidades.lista.editar']}"
								action="#{copiaFilmeBean.openUpdate}" >
								<f:setPropertyActionListener value="#{cf.id}" target="#{copiaFilmeBean.entity.id}"/>
							</h:commandLink>
						</p:column>
			
						<p:column>
							<h:commandLink value="#{bundle['locanet.entidades.lista.excluir']}"
								action="#{copiaFilmeBean.remove}" immediate="true">
								<f:setPropertyActionListener value="#{cf.id}" target="#{copiaFilmeBean.entity.id}"/>
							</h:commandLink>
						</p:column>
			
						<p:column>
							<f:facet name="header">
								<h:outputText value="#{bundle['locanet.copiaFilme.locar']}" />
							</f:facet>
							<h:commandLink action="#{locacaoBean.addNoCarrinho}" value="Adicionar a Locacao">
								<f:setPropertyActionListener value="#{cf.id}" target="#{locacaoBean.copiaFilme.id}"/>
							</h:commandLink>
						</p:column>
					</p:dataTable>
				</h:form>
				<h:form>
					<h:inputHidden value="#{filmeBean.entity.id}" />
					<h:commandLink action="#{copiaFilmeBean.openInsert}" value="#{bundle['locanet.butoes.cadastrar']} #{bundle['locanet.Filme.copias']}">
						<f:setPropertyActionListener value="#{filmeBean.entity.id}" target="#{copiaFilmeBean.filme.id}"/>
					</h:commandLink>
				</h:form>
		</p:outputPanel>
	</ui:define>
</ui:composition>
</html>